package Offer;
//翻转链表
public class Offer24reverseList {
    public ListNode reverseList(ListNode head) {
        if(head==null || head.next==null){
            return head;
        }
        ListNode  pre=null;
        ListNode curr=head;
        ListNode next=null;
        while(head!=null){
            next=curr.next;
            curr.next=pre;
            pre=curr;
            curr=next;
        }
        return pre;
    }
}
